package cn.jianml.redis.controller;

import cn.jianml.redis.entity.User;
import cn.jianml.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wujian
 * @time 2020/1/8
 */
@RestController
public class RedisController {

    @Autowired
    private RedisService redisService;

    @PostMapping("/storeToRedis")
    public String storeToRedis(User user){
        redisService.set("test", user);
        return "缓存成功";
    }

    @GetMapping("/getFromRedis")
    public Object getFromRedis(String key){
        return redisService.get(key);
    }
}
